package com.example.homework2.Interface;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.example.homework2.MainActivity;
import com.example.homework2.R;

public class UC1 extends AppCompatActivity {

    LinearLayout button_linearlayout;
    Button back, horizontal_button, vertical_button, left_button;

    String[] layout_name = {"水平布局", "垂直布局", "靠左对齐"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uc1);

        button_linearlayout = findViewById(R.id.button_linearlayout);
        horizontal_button = findViewById(R.id.horizontal_button);
        vertical_button = findViewById(R.id.vertical_button);
        left_button = findViewById(R.id.left_button);
        back = findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        horizontal_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                button_linearlayout.setOrientation(LinearLayout.HORIZONTAL);
            }
        });

        vertical_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                button_linearlayout.setOrientation(LinearLayout.VERTICAL);
            }
        });

        left_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                button_linearlayout.setGravity(Gravity.CENTER_VERTICAL|Gravity.START);
            }
        });
    }
}